package com.example.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

import java.time.Instant;

public abstract class CacheableAsyncAbstractService {

    @Autowired
    @Qualifier("schedulerTaskExecutor")
    private ThreadPoolTaskScheduler schedulerTaskExecutor;

    public void scheduleCacheOperation(Runnable runnable) {
        this.schedulerTaskExecutor.schedule(runnable, Instant.now().plusSeconds(3));
    }
}
